﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;


namespace login
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
            comboBox1.SelectedIndex = 0;
            comboBox2.SelectedIndex = 0;
            comboBox3.SelectedIndex = 0;
            comboBox4.SelectedIndex = 0;
            comboBox5.SelectedIndex = 0;
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }


        private void tableLayoutPanel1_Paint(object sender, PaintEventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {
            Form1 form1 = new Form1();
            this.Hide();
            form1.StartPosition = FormStartPosition.CenterScreen;
            form1.Show();
        }

        private void button1_Click_1(object sender, EventArgs e)
        {
            String flag = "";
            UserInfoModel uim = new UserInfoModel();

            if (textBox1.Text.Trim() == "")
            {
                flag = "请填写姓名";
            }
            else
            {
                uim.Name = textBox1.Text.Trim();
            }
            if (comboBox1.Text == "男") {
                uim.Gender = false;
            }
            else if (comboBox1.Text == "女") {
                uim.Gender = true;
            }else {
                flag = "请填写性别";
            }
            uim.Birth = dateTimePicker1.Value;
            if (comboBox5.Text == "良好"){
                uim.HealthState = 1;
            }
            else if (comboBox5.Text == "体弱") {
                uim.HealthState = 2;
            }
            else if (comboBox5.Text == "残疾") {
                uim.HealthState = 3;
            }
            else {
                flag = "请填写健康状况";
            }
            if (comboBox2.Text == "未婚") {
                uim.MarriageState = false;
            }
            else if (comboBox2.Text == "已婚") {
                uim.MarriageState = true;
            }
            else {
                flag = "请填写婚姻状况";
            }
            if (textBox3.Text.Trim() == "")
            {
                flag = "请填写籍贯";
            }
            else
            {
                uim.BirthPlace = textBox3.Text.Trim();
            }
            if (comboBox3.Text == "小学") {
                uim.EducationLevel = 1;
            }
            else if (comboBox3.Text == "初中") {
                uim.EducationLevel = 2;
            }
            else if (comboBox3.Text == "高中") {
                uim.EducationLevel = 3;
            }
            else if (comboBox3.Text == "本科") {
                uim.EducationLevel = 4;
            }
            else if (comboBox3.Text == "硕士") {
                uim.EducationLevel = 5;
            }
            else if (comboBox3.Text == "博士") {
                uim.EducationLevel = 6;
            }
            else
            {
                flag = "请填写文化程度";
            }
            if (comboBox4.Text == "清白") {
                uim.PolicitalStatus = 1;
            }
            else if (comboBox4.Text == "共青团员") {
                uim.PolicitalStatus = 2;
            }
            else if (comboBox4.Text == "中共党员") {
                uim.PolicitalStatus = 3;
            }
            else if (comboBox4.Text == "民主党派党员") {
                uim.PolicitalStatus = 4;
            }
            else
            {
                flag = "请填写政治面貌";
            }
            if (textBox4.Text.Trim() == "")
            {
                flag = "请填写身份证号码";
            }
            else
            {
                uim.IDNumber = textBox4.Text.Trim();
            }
            if (textBox5.Text.Trim() == "")
            {
                flag = "请填写户籍地址";
            }
            else
            {
                uim.AddressHometown = textBox5.Text.Trim();
            }
            if (textBox6.Text.Trim() == "")
            {
                flag = "请填写现住地址";
            }
            else
            {
                uim.AddressNow = textBox6.Text.Trim();
            }
            if (textBox7.Text.Trim() == "")
            {
                flag = "请填写电话";
            }
            else
            {
                uim.Telephone = textBox7.Text.Trim();
            }

            if(flag != ""){
                MessageBox.Show(flag);
                return;
            }

            String str = uim.EntityToJson(uim);
            Form3 form3 = new Form3(str);
            this.Hide();
            form3.StartPosition = FormStartPosition.CenterScreen;
            form3.Show();
        }



    }
}
